import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/kq_screen_util.dart';
import 'package:kq_flutter_core_widget/utils/kq_multi_click_util.dart';
import 'package:kq_flutter_core_widget/widgets/button/kq_ink_well.dart';

import '../../resources/kq_theme_colors.dart';


/// 通用下划线按钮
///
/// @author 周卓
///
/// 透明背景，带下划线，文字颜色和下划线颜色一致
class KqUnderlineButton extends StatelessWidget {
  /// 文字
  final String title;

  /// 文字颜色，默认蓝色
  final Color? textColor;

  /// 文字大小，默认16
  final double? fontSize;

  /// 文字对齐方式
  final TextAlign textAlign;

  /// 点击事件
  final GestureTapCallback? onTap;

  /// 水平左右padding，默认0
  final double? horizontalPadding;

  /// 垂直左右padding，默认0
  final double? verticalPadding;

  const KqUnderlineButton({
    Key? key,
    required this.title,
    this.textColor = KqThemeColors.textBlue,
    this.textAlign = TextAlign.right,
    this.fontSize,
    this.horizontalPadding,
    this.verticalPadding,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return KqInkWell(
        onTap: () {
          if (KqMultiClickUtil.isMultiClick()) {
            return;
          }
          onTap?.call();
        },
        horizontalPadding: horizontalPadding ?? 0,
        verticalPadding: verticalPadding ?? 0,
        child: Text(
          title,
          textAlign: textAlign,
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(
              color: textColor,
              fontSize: fontSize ?? 16.sp,
              decoration: TextDecoration.underline),
        ));
  }
}
